package miracle.joker.design.command.demo1;

public class CommandDemo {
    public static void main(String[] args) {
        TV tv = new TV();

        Command tvOnCommand = new TVOnCommand(tv);
        Command tvOffCommand = new TVOffCommand(tv);
        Command tvVolumeUpCommand = new TVVolumeUpCommand(tv);
        Command tvVolumeDownCommand = new TVVolumeDownCommand(tv);

        RemoteControl remoteControl = new RemoteControl();

        remoteControl.setCommand(0, tvOnCommand, tvOffCommand);
        remoteControl.setCommand(1, tvVolumeUpCommand, tvVolumeDownCommand);

        remoteControl.onButtonPressed(0);
        // 输出：TV is on

        remoteControl.offButtonPressed(0);
        // 输出：TV is off

        remoteControl.onButtonPressed(1);
        // 输出：TV volume is increased

        remoteControl.offButtonPressed(1);
        // 输出：TV volume is decreased

        remoteControl.undoButtonPressed();
        // 输出：TV volume is increased
    }
}
